package Random_;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Scanner;

public class Test08 {
    public static void main(String[] args) {
        FileWriter f = null;
        BufferedWriter b = null;
        try {
            f = new FileWriter("F:\\传奇永不熄灭.txt");
            b = new BufferedWriter(f);
            while (true) {
                Scanner input = new Scanner(System.in);
                System.out.println("输入字符");
                long start = System.currentTimeMillis();
                String a = input.next();
                if (a.equals("quit")) {
                    System.out.println("退出");
                    return;
                } else {
                    long end = System.currentTimeMillis();
                    b.write(new SimpleDateFormat("hh:mm:ss  ").format(end - start) + a);
                    b.newLine();
                    b.flush();
                    System.out.println(new SimpleDateFormat("hh:mm:ss  ").format(end - start) + a);

                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                b.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                f.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
